#pragma once
#include"RBTree.h"


namespace lbj
{
	template<class K,class T>
	class map
	{
	public:
		struct MapKeyOfT
		{
			const K& operator()(const pair<K,T>& kv)
			{
				return kv.first;
			} 
		};

		typedef typename RBTree<K, T, MapKeyOfT>::iterator iterator;
		iterator begin()
		{
			return _t.Begin();
		}
		iterator end()
		{
			return _t.End();
		}

		T& operator[](const K& key)
		{
			pair<iterator, bool> ret = insert(make_pair(key, T()));
			return ret.first->second;
		}

		pair<iterator, bool> insert(const pair<K,T>& kv)
		{
			return _t.Insert(kv);
		}
	private:
		RBTree<K, pair<K, T>, MapKeyOfT> _t;
	};
} 